package cn.itcast.account.service;

import io.seata.rm.tcc.api.BusinessActionContext;
import io.seata.rm.tcc.api.BusinessActionContextParameter;
import io.seata.rm.tcc.api.LocalTCC;
import io.seata.rm.tcc.api.TwoPhaseBusinessAction;
import org.springframework.web.bind.annotation.PathVariable;

/**
 * TCC补偿接口
 */
@LocalTCC
public interface TCCAccountService {

    /**
     * 表示try阶段
     * name表示当前阶段的名称，名称可以随意起
     * commitMethod表示提交成功的方法名称
     * rollbackMethod表示回滚的方法名称
     */
    @TwoPhaseBusinessAction(name = "tryTCC",commitMethod = "confirmTcc",rollbackMethod = "cancelTcc")
    public void tryTcc(@BusinessActionContextParameter(paramName = "userId") String userId, @BusinessActionContextParameter(paramName = "money") Integer money);

    //提交
    public boolean confirmTcc(BusinessActionContext bac);
    //回滚
    public boolean cancelTcc(BusinessActionContext bac);
}
